<template>
  <div class="app-container">
    <div id="map"></div>
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="门店名称" prop="storeName">
        <el-input
          v-model="queryParams.storeName"
          placeholder="请输入门店名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          v-hasPermi="['business:projectList:query']"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:projectList:add']"
          >新增</el-button
        >
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
        >修改</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:projectList:del']"
          >批量删除</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table
      v-loading="loading"
      :data="storeList"
      max-height="650px"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column label="序号" align="center" prop="storeName" /> -->
     
      <el-table-column
        label="适用区域"
        align="center"
        :show-overflow-tooltip="true"
        prop="regionName"
        width="120"
      />
      <el-table-column
        label="适用门店"
        align="center"
        :show-overflow-tooltip="true"
        prop="storeName"
      />
      <el-table-column label="项目图片" align="center" prop="img" width="120">
        <template slot-scope="scope">
          <image-preview :src="scope.row.img" :width="70" :height="70" />
        </template>
      </el-table-column>
      <el-table-column
        label="项目名称"
        align="center"
        :show-overflow-tooltip="true"
        prop="itemName"
      />
      <el-table-column
        label="项目分类名称"
        width="120"
        :show-overflow-tooltip="true"
        align="center"
        prop="typeName"
      />
     
      <el-table-column label="服务时长" align="center" prop="duration" />
      <el-table-column label="价格" align="center" prop="price" />
      <el-table-column label="次数" align="center" prop="times" />
      <el-table-column label="提成金额" align="center" prop="royalty" />
      <el-table-column label="排列" align="center" prop="orderNum" />
     
      <el-table-column label="上架状态" align="center" prop="status">
        <template slot-scope="scope">
          <span>{{ scope.row.status == "1" ? "上架" : "下架" }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="小程序端是否显示"
        align="center"
        prop="minProIsShow"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.minProIsShow == "1" ? "是" : "否" }}</span>
        </template>
      </el-table-column>
      <el-table-column label="创建人"   align="center"  prop="createBy" />
      <el-table-column label="创建时间"   align="center"  prop="createTime" />
      <el-table-column label="修改人"   align="center"  prop="updateBy" />
      <el-table-column label="修改时间"   align="center"  prop="updateTime" />

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        width="250"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:projectList:edit']"
            >修改</el-button
          >
          <!-- <el-button size="mini" type="text" icon="el-icon-edit" @click="handleAdd2(scope.row)"
            v-hasPermi="['business:projectList:addTechnician']">添加技师</el-button> -->
          <el-button
            size="mini"
            type="text"
            icon="el-icon-upload2"
            @click="handleGround(scope.row, (status = 1))"
            v-hasPermi="['business:projectList:listing']"
            :disabled="scope.row.status === 1"
            >上架</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleGround(scope.row, (status = 2))"
            v-hasPermi="['business:projectList:offShelf']"
            :disabled="scope.row.status === 2"
            >下架</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:projectList:del']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <el-dialog
      :title="'所属技师'"
      :visible.sync="technician"
      width="500px"
      append-to-body
      :close-on-click-modal="false"
    >
      <el-form ref="form2" :model="form" :rules="rules" label-width="120px">
        <el-form-item label="所属技师" prop="technicianIdList">
          <el-select multiple clearable v-model="form2.technicianIdList">
            <el-option
              v-for="(item, index) of technicianIdList"
              :key="index"
              :label="item.value"
              :value="item.key"
              >{{ item.value }}</el-option
            >
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitList">确 定</el-button>
        <el-button @click="cancelList">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 添加或修改门店对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="区域" prop="regionId">
              <el-select
                clearable
                v-model="form.regionId"
                @change="changeRegion"
              >
                <el-option
                  v-for="(item, index) of region"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <!-- 适用门店1 -->
            <el-form-item label="适用门店" prop="storeIds" v-if="isAdd">
              <el-select
                clearable
                v-model="form.storeIds"
                @change="changestoreId"
                multiple
              >
                <el-option
                  v-for="(item, index) of store"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select>
            </el-form-item>

            <!-- 适用门店2 -->
            <el-form-item label="适用门店" prop="storeId" v-if="!isAdd">
              <el-select
                clearable
                v-model="form.storeId"
                @change="changestoreId"
              >
                <el-option
                  v-for="(item, index) of store"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="项目分类" prop="typeId">
              <el-select
                clearable
                v-model="form.typeId"
                @change="changepullDown"
              >
                <el-option
                  v-for="(item, index) of pullDown"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目名称" prop="itemName">
              <el-input
                v-model="form.itemName"
                placeholder="请输入项目名称"
                style="width: 222px"
              />

              <!-- <el-select clearable v-model="form.itemId" @change="changeitemId">
                <el-option
                  v-for="(item, index) of storepullDown"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="排序" prop="orderNum">
          <el-input
            v-model="form.orderNum"
            placeholder="请输入排序"
            style="width: 222px"
          />
        </el-form-item>
        <el-form-item label="项目图片" prop="img">
          <image-upload v-model="form.img" />
        </el-form-item>
        <!-- <el-form-item label="项目详情图片" prop="detailsImg">
          <image-upload v-model="form.detailsImg" />
        </el-form-item> -->

        <el-row>
          <el-col :span="12">
            <el-form-item label="项目时长" prop="duration">
              <el-input
                v-model="form.duration"
                placeholder="请输入项目时长（分钟）"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="正常价" prop="price">
              <el-input
                v-model="form.price"
                placeholder="请输入正常价"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <!-- <el-row>
          <el-col :span="12" v-if="this.memberType === 1">
            <el-form-item label="会员价" prop="member">
              <el-input
                v-model="form.member"
                placeholder="请输入会员价"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12" v-else>
            <el-form-item label="会员折扣" prop="discount">
              <el-input
                v-model="form.discount"
                placeholder="请输入会员折扣价"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
        </el-row> -->

        <el-row>
          <el-col :span="12">
            <el-form-item label="项目提成" prop="royalty">
              <el-input
                v-model="form.royalty"
                placeholder="请输入项目提成"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="适用人群" prop="applyPeople">
              <el-input
                v-model="form.applyPeople"
                placeholder="请输入适用人群"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="调理方法" prop="method">
              <el-input
                v-model="form.method"
                placeholder="请输入调理方法"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="调理流程" prop="flow">
              <el-input
                v-model="form.flow"
                placeholder="请输入调理流程"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <el-form-item label="禁忌症" prop="contraindication">
              <el-input
                v-model="form.contraindication"
                placeholder="请输入禁忌症"
                style="width: 222px"
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="上架状态" prop="status">
              <el-select clearable v-model="form.status">
                <el-option
                  v-for="(item, index) of List"
                  :key="index"
                  :label="item.value"
                  :value="item.key"
                  >{{ item.value }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="次数选择" prop="times">
              <el-select clearable v-model="form.times">
                <el-option
                  v-for="(item, index) of timesList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="小程序显示" prop="minProIsShow">
              <el-select clearable v-model="form.minProIsShow">
                <el-option
                  v-for="(item, index) of showList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
                  >{{ item.label }}</el-option
                >
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listitemList,
  getItemType,
  delitemStore,
  addItemStore,
  listtechnicianList,
  addtechnician,
  listtechnician,
  updateitemStore,
  listResetPwd,
  listMemberRegion,
  listMemberStore,
  listpullDownlist,
  liststorelist,
} from "@/api/system/projectList/projectList";

export default {
  name: "Store",
  data() {
    return {
      map: null,
      local: null,
      mk: null,
      latitude: "",
      longitude: "",
      keyWords: "",
      result: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      technician: false,
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 门店表格数据
      storeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      form2: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        storeName: null,
        phoneNumber: null,
        province: null,
        provinceString: null,
        city: null,
        cityString: null,
        county: null,
        countyString: null,
        detail: null,
        longitude: null,
        latitude: null,
        intro: null,
        images: null,
        status: null,
        isInitiate: null,
        openingTime: null,
        closingTime: null,
        times: null,
        minProIsShow: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        regionId: [{ required: true, message: "请输入区域", trigger: "blur" }],
        storeId: [
          { required: true, message: "请选择适用门店", trigger: "blur" },
        ],
        typeId: [
          { required: true, message: "请选择项目分类", trigger: "blur" },
        ],
        times: [{ required: true, message: "请选择", trigger: "blur" }],
        minProIsShow: [{ required: true, message: "请选择", trigger: "blur" }],
        itemId: [
          { required: true, message: "请选择项目名称", trigger: "blur" },
        ],
        img: [{ required: true, message: "请上传图片", trigger: "blur" }],
        detailsImg: [
          { required: true, message: "请上传图片", trigger: "blur" },
        ],
        duration: [
          { required: true, message: "请输入项目时长", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.[0-9]+)?$/,
            message: "请输入正确项目时长",
            trigger: "blur",
          },
        ],
        price: [
          { required: true, message: "请输入正常价", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.[0-9]+)?$/,
            message: "请输入正确正常价",
            trigger: "blur",
          },
        ],
        member: [
          { required: true, message: "请输入会员价", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.[0-9]+)?$/,
            message: "请输入正确会员价",
            trigger: "blur",
          },
        ],
        discount: [
          { required: true, message: "请输入折扣", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.[0-9]+)?$/,
            message: "请输入正确折扣",
            trigger: "blur",
          },
        ],
        royalty: [
          { required: true, message: "请输入项目提成", trigger: "blur" },
          {
            pattern: /^[0-9]+(\.[0-9]+)?$/,
            message: "请输入正确项目提成",
            trigger: "blur",
          },
        ],
        /**applyPeople: [
          { required: true, message: '请输入适用人群', trigger: 'blur' },
      ],
      method: [
          { required: true, message: '请输入调理方法', trigger: 'blur' },
      ],
      flow: [
          { required: true, message: '请输入条例流程', trigger: 'blur' },
    ],
      contraindication: [
          { required: true, message: '请输入禁忌症', trigger: 'blur' },
      ],*/
        itemName: [
          { required: true, message: "请输入项目名称", trigger: "blur" },
        ],
        status: [{ required: true, message: "请选择上架", trigger: "blur" }],
      },
      options: [],
      List: [
        {
          key: 1,
          value: "上架",
        },
        {
          key: 2,
          value: "下架",
        },
      ],
      timesList: [
        {
          value: 0.5,
          label: "0.5",
        },
        {
          value: 1,
          label: "1",
        },
        {
          value: 1.5,
          label: "1.5",
        },
        {
          value: 2,
          label: "2",
        },
        {
          value: 2.5,
          label: "2.5",
        },
        {
          value: 3,
          label: "3",
        },
        {
          value: 3.5,
          label: "3.5",
        },
        {
          value: 4,
          label: "4",
        },
        {
          value: 4.5,
          label: "4.5",
        },
        {
          value: 5,
          label: "5",
        },
        {
          value: 5.5,
          label: "5.5",
        },
        {
          value: 6,
          label: "6",
        },
        {
          value: 6.5,
          label: "6.5",
        },
        {
          value: 7,
          label: "7",
        },
        {
          value: 7.5,
          label: "7.5",
        },
        {
          value: 8,
          label: "8",
        },
        {
          value: 8.5,
          label: "8.5",
        },
        {
          value: 9,
          label: "9",
        },
        {
          value: 9.5,
          label: "9.5",
        },
        {
          value: 10,
          label: "10",
        },
      ],
      showList: [
        {
          value: 1,
          label: "显示",
        },
        {
          value: 2,
          label: "不显示",
        },
      ],
      region: [],
      store: [],
      pullDown: [],
      storepullDown: [],
      technicianIdList: [],
      memberType: 1,
      isAdd: true,
    };
  },
  created() {
    this.getList();
    this.listregion();
    // listpullDownlist().then((res) => {
    //   console.log(res, 123);
    //   this.pullDown = res.data.map((rItem) => {
    //     return {
    //       key: rItem.id,
    //       value: rItem.typeName,
    //     };
    //   });
    // });
    liststorelist().then((res) => {
      this.storepullDown = res.data.map((rItem) => {
        return {
          key: rItem.id,
          value: rItem.itemName,
        };
      });
    });
    // listMemberStore().then((res) => {
    //   this.store = res.data.map((rItem) => {
    //     return {
    //       key: rItem.id,
    //       value: rItem.storeName,
    //       memberType: rItem.memberType
    //     }
    //   })
    // })
  },
  methods: {
    listregion() {
      listMemberRegion().then((res) => {
        this.region = res.data.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.regionName,
          };
        });
      });
    },

    changeRegion(value) {
      this.form.storeId = "";
      const selectedOption = this.region.find((item) => item.key === value);
      const selectedKey = selectedOption.key;
      const selectedValue = selectedOption.value;
      console.log(`Selected Key: ${selectedKey}`);
      console.log(`Selected Value: ${selectedValue}`);
      this.form.regionName = selectedValue;
      //
      listMemberStore({ regionId: value }).then((res) => {
        console.log(res, "数据");
        this.store = res.data.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.storeName,
            memberType: rItem.memberType,
          };
        });
      });
      listpullDownlist({ regionId: value }).then((res) => {
        console.log(res, 123);
        this.pullDown = res.data.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.typeName,
          };
        });
      });
    },

    changepullDown(value) {
      const selectedOption = this.pullDown.find((item) => item.key === value);
      const selectedKey = selectedOption.key;
      const selectedValue = selectedOption.value;
      console.log(`Selected Key: ${selectedKey}`);
      console.log(`Selected Value: ${selectedValue}`);
      this.form.typeName = selectedValue;
      liststorelist({ typeId: value }).then((res) => {
        this.storepullDown = res.data.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.itemName,
          };
        });
      });
    },
    changestoreId(value) {
      // const selectedOption = this.store.find((item) => item.key === value)
      //  console.log(selectedOption,99999);
      //this.memberType = selectedOption.memberType
      // const selectedValue = selectedOption.value;
      // this.form.storeName = selectedValue;
    },
    changeitemId(value) {
      const selectedOption = this.storepullDown.find(
        (item) => item.key === value
      );
      const selectedKey = selectedOption.key;
      const selectedValue = selectedOption.value;
      console.log(`Selected Key: ${selectedKey}`);
      console.log(`Selected Value: ${selectedValue}`);
      this.form.itemName = selectedValue;
    },
    /** 查询门店列表 */
    getList() {
      this.loading = true;
      listitemList(this.queryParams).then((response) => {
        this.storeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    handleAdd2(row) {
      console.log(row);
      this.technician = true;
      this.form2.itemStoreId = row.id;
      listtechnician({ belongStoreId: row.storeId }).then((res) => {
        console.log(res, 333);
        this.technicianIdList = res.data.map((rItem) => {
          return {
            key: rItem.id,
            value: rItem.name,
          };
        });
      });
      listtechnicianList({ itemStoreId: row.id }).then((res) => {
        console.log(res, 888);
        this.form2.technicianIdList = res.data;
      });
    },
    submitList() {
      console.log(this.form2.technicianIdList, 999);
      addtechnician(this.form2).then((res) => {
        console.log(res, 123);
        if (res.code == 200) {
          this.technician = false;
          this.reset2();
        }
      });
    },
    cancelList() {
      this.technician = false;
      this.reset2();
    },
    reset2() {
      this.form2 = {
        itemStoreId: null,
        technicianIdList: null,
      };
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        storeName: null,
        phoneNumber: null,
        province: null,
        provinceString: null,
        city: null,
        cityString: null,
        county: null,
        countyString: null,
        detail: null,
        longitude: null,
        latitude: null,
        intro: null,
        images: null,
        status: null,
        isInitiate: null,
        openingTime: null,
        closingTime: null,
        createTime: null,
        updateTime: null,
        times: null,
        minProIsShow: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加门店项目";
      this.isAdd = true;
    },
    // 上下架
    handleGround(row, status) {
      const params = {
        id: row.id,
        status: status,
      };
      this.$confirm(
        `此操作将${status === 1 ? "上架" : "下架"}该数据, 是否继续?`,
        "提示",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          updateitemStore(params).then((res) => {
            this.$message({
              type: "success",
              message: `${status === 1 ? "上架" : "下架"}成功!`,
            });
            this.getList();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消上下架",
          });
        });
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getItemType(id).then((response) => {
        this.form = response.data;
        console.log(response, 1111);
        this.form.minProIsShow = response.data.minProIsShow - 0;
        this.memberType = response.data.memberType;
        this.open = true;
        this.title = "修改门店项目";
        this.isAdd = false;

        listpullDownlist({ regionId: response.data.regionId }).then((res) => {
          console.log(res, 123);
          this.pullDown = res.data.map((rItem) => {
            return {
              key: rItem.id,
              value: rItem.typeName,
            };
          });
        });
        liststorelist({ typeId: response.data.typeId }).then((res) => {
          this.storepullDown = res.data.map((rItem) => {
            return {
              key: rItem.id,
              value: rItem.itemName,
            };
          });
        });

        listMemberStore({ regionId: this.form.regionId }).then((res) => {
          this.store = res.data.map((rItem) => {
            return {
              key: rItem.id,
              value: rItem.storeName,
              memberType: rItem.memberType,
            };
          });
        });
      });
    },

    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateitemStore(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addItemStore(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    handReset(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认重置编号为"' + ids + '"的数据项？')
        .then(function () {
          return listResetPwd({ userId: ids });
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("重置成功");
        })
        .catch(() => {});
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除编号为"' + ids + '"的数据项？')
        .then(function () {
          return delitemStore(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/store/export",
        {
          ...this.queryParams,
        },
        `store_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style>
.dialog-footer {
  text-align: center;
}
</style>
